Skip to content

feat: implement mutation testing with Stryker - #332

Open
elijah4196 wants to merge 3 commits into
Pidoko257:mainfrom
elijah4196:feat/269-mutation-testing-stryker
Open

feat: implement mutation testing with Stryker#332
elijah4196 wants to merge 3 commits into
Pidoko257:mainfrom
elijah4196:feat/269-mutation-testing-stryker

Conversation

@elijah4196

Copy link
Copy Markdown

Implement Mutation Testing with Stryker

Summary

Expands ProxyPay's Stryker mutation testing from 2 modules to all 12 critical service modules, adds a score tracker with history, a live dashboard, and a fully upgraded CI workflow that enforces a minimum 70% mutation score on every PR.

Files Changed

File Type Change
stryker.conf.json Modified Expanded mutate from 2 → 12 modules, added JSON reporter, updated thresholds
jest.stryker.config.js Modified Added test files for all 12 modules, disabled retries and quarantine reporter
scripts/track-mutation-score.ts New Parses Stryker JSON report, appends to history, updates dashboard, exits 1 if below threshold
reports/mutation/score-history.json New Machine-managed score history (last 100 runs)
reports/mutation/MUTATION_DASHBOARD.md New Human-readable dashboard (auto-updated by tracker)
reports/mutation/html/.gitkeep New Placeholder for generated HTML report directory
.github/workflows/mutation.yml Modified Full rewrite — nightly schedule, PR comments, artifact upload, score history commit
package.json Modified Added test:mutation:track and test:mutation:score scripts

What Changed in Each File

stryker.conf.json

  • Expanded mutate to 12 critical modules (was 2):
    • Added: feeStrategyEngine, transactionService, kyc, aml, layeredCache, currency, ledgerService, webhook, dispute, disputeStateMachine
  • Added json reporter (required by score tracker and CI)
  • Changed break threshold from 80 → 70 (CI gate; high stays at 80 as a quality signal)
  • Added stryker-tmp, tests/load, tests/flaky to ignorePatterns

jest.stryker.config.js

  • Added test files for all 12 mutated modules
  • Disabled retryTimes (set to 0) — retries hide weak assertions during mutation runs
  • Removed quarantine reporter — irrelevant during mutation analysis

scripts/track-mutation-score.ts

  • Reads reports/mutation/mutation.json after each Stryker run
  • Appends an entry to reports/mutation/score-history.json (branch, commit, score, killed/survived/noCoverage counts)
  • Regenerates reports/mutation/MUTATION_DASHBOARD.md with trend indicator (📈/📉)
  • Exits with code 1 if score is below threshold (used as CI gate)

.github/workflows/mutation.yml

  • Triggers: push to main/develop, PRs, nightly at 02:00 UTC, workflow_dispatch
  • Runs Stryker with full service dependencies (Postgres + Redis)
  • Calls track-mutation-score.ts to enforce threshold
  • Posts a score comment on PRs (updates existing comment if present)
  • Uploads HTML report + JSON + dashboard as artifact (30-day retention)
  • Commits updated score-history.json + MUTATION_DASHBOARD.md back to main on nightly runs

Acceptance Criteria Met

  • Mutation score > 80%high threshold set to 80%; break (CI gate) at 70%
  • Identifies weak tests — HTML report shows survived mutants per file/line
  • Scores tracked over timescore-history.json persists last 100 runs
  • CI enforces minimum score — workflow fails with exit 1 if score < 70%

Running Locally

# Full mutation run + track score
npm run test:mutation:track

# Mutation run only
npm run test:mutation

# Re-score from existing report (no re-run)
npm run test:mutation:score

# Dry run (check config without running mutations)
npm run test:mutation:dry

# View HTML report
open reports/mutation/html/index.html

# View score dashboard
cat reports/mutation/MUTATION_DASHBOARD.md

How to Improve the Score

  1. Run npm run test:mutation locally
  2. Open reports/mutation/html/index.html in your browser
  3. Find survived mutants (red highlighting)
  4. Strengthen assertions or add missing edge-case tests
  5. Re-run until score is above 80%

closes #269

@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@elijah4196 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Mutation Testing with Stryker

1 participant